import React from 'react'
import styles from './index.less'
import { Row, Col, Button,Form, Input, Icon, Radio,Modal } from 'antd'
import {format} from '../../utils'
import driverLogo from '../../../assets/driverLogo.png'

const confirm = Modal.confirm
const FormItem = Form.Item;
const RadioButton = Radio.Button;
const RadioGroup = Radio.Group;
const formItemLayout = {
  labelCol: {
    span: 24,
		
  },
  wrapperCol: {
    span:12
  },
}
class edit extends React.Component {
    render() {
        const {onOk, detail,onClose} = this.props
        const { getFieldDecorator } = this.props.form;
        const handleSubmit = (e) => {
            e.preventDefault();
            this.props.form.validateFields((err, values) => {
            if (!err) {
               let data={
                   orderSerial:detail.orderSerial,
                   orderStatus:values.orderStatus,
                }
                onOk(data)
                localStorage.setItem("editorder",'true')
            }
            });
        }
        const btnstyle ={
            margin:'0 10',
        }
    
    const editorder =(e)=>{
        localStorage.setItem("editorder",'false')
    }    
    const Close =()=>{
        confirm({
          title: '温馨提示',
          content: '你填写的内容还没保存，确认退出会清空你填写的内容，确认退出编辑吗？',
          okText: '确认',
          okType: 'danger',
          cancelText: '取消',
          onOk() {
            localStorage.setItem("editorder",'true')
            onClose()
          },
        });
    }
    return (
      <div>
        <div className={styles.filterTop}>
            <div className={styles.title}><span style={{marginRight:20}}>修改订单状态</span>
            <Button type="primary" onClick={handleSubmit}>保存</Button>
            </div>
            <div className={styles.Searchright} >
                <Icon type="close" onClick={Close} style={{ fontSize: 24, color: '#000',cursor: 'pointer',fontWeight:'bold' }} />
            </div>
        </div>
        <div className={styles.listbox}>
            <Form onSubmit={handleSubmit} onChange ={editorder} className="login-form" >
                <FormItem {...formItemLayout} label="修改订单状态">
                {getFieldDecorator('orderStatus', {
                    initialValue:detail.orderStatus,
                })(
                    <RadioGroup size="large">
                        <RadioButton value={0} className={styles.editbk}>代接单</RadioButton>
                        <RadioButton value={10} className={styles.editbk}>已作废</RadioButton>
                    </RadioGroup>
                )}
                </FormItem>
            </Form>
        </div>
      </div>
    );
  }
}
export default Form.create()(edit)
